package com.up.upzl.biz.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.up.upzl.base.domain.BaseDomain;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 应用
 * 
 * @author geeks
 *
 */
@Getter
@Setter
@Entity
@NoArgsConstructor
public class SysApp extends BaseDomain {

	private static final long serialVersionUID = 411670013174908291L;

	/**
	 * 权限查询构造器
	 */
	public SysApp(Long id, String appName, String appAction, String font, Integer sort, Long parentId) {
		this.setId(id);
		this.appName = appName;
		this.appAction = appAction;
		this.font = font;
		this.sort = sort;
		this.parentId = parentId;
	}

	/**
	 * 应用名称
	 */
	@Column(length = 32, unique = true)
	private String appName;

	/**
	 * 应用类型
	 */
	private Type type;

	public enum Type {
		一级页面, 二级页面, 页面功能
	}

	/**
	 * 应用路由
	 */
	@Column(unique = true)
	private String appAction;

	/**
	 * 左侧小图标
	 */
	@Column(length = 32)
	private String font;

	/**
	 * 排序
	 */
	private Integer sort;

	/**
	 * 域名
	 */
	private String domainName;

	/**
	 * 父ID
	 */
	@Column(insertable = false, updatable = false)
	private Long parentId;

	/**
	 * 父级应用
	 */
	@ManyToOne
	@JoinColumn(name = "parentId")
	private SysApp parentSysApp;

	/**
	 * 子级应用
	 */
	@OneToMany(mappedBy = "parentSysApp")
	private List<SysApp> subSysApps;

}
